$.fn.searchword = function() {

    var $dictionary = new RockitJS.Model.Database.Dictionary();
    
    var _resultTranslate = function($result)
    {
        var $count = $result.rows.length;
        var $translate = new Object();

        for ($i = 0; $i < $count; $i++) {
            for ($column in $result.rows.item($i)) {

                $translate[$column] = $result.rows.item($i)[$column];
                //alert($translate[$column] +", "+ $result.rows.item($i)[$column]);    
            }
            //$("#dictionary").html($result.rows.item($i).word);
        }
        /*
        for (a in $translate) {
            alert(a);
            for (b in a) {
                alert(b);
            }
        }*/
            
        //$dictionary.getAllWords();
    }

    var _resultWord = function($result)
    {

        var $htmlLink = '<li><a href="#" class="dictionary" name="{ID}" title="{LANGUAGE}"><img src="images/flags/{LANGUAGE}.png"> {LABEL}</a></li>';
        var $nav = "";
        var $count = $result.rows.length;

        for ($i = 0; $i < $count; $i++) {

        	var $link = $htmlLink;
            $link = $link.replace(/{LANGUAGE}/g, $result.rows.item($i).language);
            $link = $link.replace(/{LABEL}/g, $result.rows.item($i).word);
            $link = $link.replace(/{ID}/g, $result.rows.item($i).id);
            $nav += $link;
        }

         $("#dictionary #list").html($nav);
//#dictionary #list li 
         $('a').bind('click', function() {

            $dictionary.getTranslate($(this).attr("name"), $(this).attr("title"), _resultTranslate);
         });

    };

    $(this).keyup(
        function () {

            $dictionary.search($(this).attr("value"), _resultWord);
        }
    );
}